package test

import config.MyFile
import org.apache.commons.io.FileUtils

import java.io.File
import scala.jdk.CollectionConverters._

object GetCode extends MyFile{

  def main(args: Array[String]): Unit = {

    getLines("G:\\workspace\\camellia_oleifera_abel_db\\public\\phylotree.js-master\\vis.min.js".toFile,"H:\\南农油茶数据库/code.txt".toFile)

  }

  def getLines(x: File, all: File): Unit = {
    if (x.isDirectory) {
      x.listFiles().foreach { y =>
        getLines(y, all)
      }
    } else {
      FileUtils.writeLines(all, x.readLines.asJava, true)
      x.readLines
    }
  }

  def allFiles: List[File] = {

    def loop(acc: List[File], files: List[File]): List[File] = {
      files match {
        case Nil => acc
        case x :: xs => x.isDirectory match {
          case false => loop(x :: acc, xs)
          case true => loop(acc, xs ::: x.listFiles().toList)
        }
      }
    }

    loop(List(), List("G:\\workspace\\Phycophyta_organelle_database\\app".toFile))
  }

}
